package com.geekaca.net712;

import java.io.*;

public class Demo {
    private static String path = "c:\\temp\\dataOut.txt";

    /**
     * 把数据,信息写入到文件
     */
    public static void main(String[] args) {

//        try (FileOutputStream fos = new FileOutputStream(path);
//             DataOutputStream dos = new DataOutputStream(fos);) {
//            dos.writeInt(9);
//            dos.writeUTF("你好");
//            dos.flush();
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        read();
    }


    public static void read() {
        try (FileInputStream fis = new FileInputStream(path);
             DataInputStream dis = new DataInputStream(fis);) {
            int i = dis.readInt();
            String s = dis.readUTF();
            System.out.println(i);
            System.out.println(s);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }

}
